<?php
namespace wlcat\http\MiddleWare;
use wlcat\src\Request;

class RemoveMagicQuotesFrameMiddleWare implements MiddleFrameWareInterface {
    public function handle(Request $request, \Closure $next)
    {
        if ( get_magic_quotes_gpc()) {
            $methods = $request->getMethods();
            foreach ($methods as $method) {
                $request->setInput($methods.'.',
                    $this->stripSlashesDeep($request->input($methods.'.'))
                );
            }
        }
        return $next($request);
    }
    // 删除敏感字符
    function stripSlashesDeep($value)
    {
        $value = is_array($value) ? array_map('stripSlashesDeep', $value) : stripslashes($value);
        return $value;
    }

}